//let cookies = 'visit=22; age=18;   visit=23; visit=244';
//let result = cookies.match(/visit=([^;]*)/g);
//let result = cookies.match(/(?:(^|;\s+))visit=([^;]*)/g);
//let result = cookies.match(/(?:^|;\s+)visit=([^;]*)(?:;|$)/g);
//console.log(result)

let cookies = 'a=1; visit=2; b=3';
let result = cookies.match(/visit=([^;]*)/);
console.log(result[1])